<cfprocessingdirective pageEncoding="utf-8" />
	<cfscript>
	role = event.getValue('role');
	
	preferences = "";
	permissions = "";
	
	permissionList = event.getValue( 'Permission.list' ).iterator();
	preferenceList = event.getValue( 'Preference.list' ).iterator();
	
	rolePermissions = role.getPermissions().iterator(); 
	rolePreferences = role.getPreferences().iterator();
	
	while( rolePermissions.hasNext() ){
	
		permissions = listAppend( permissions, rolePermissions.next().getIdPermission(), "," );
	
	}
	
	while( rolePreferences.hasNext() ){
	
		preferences = listAppend( preferences, rolePreferences.next().getIdPreference(), "," );
	
	}
	
	validator = event.getValue('error', structNew() );
	action = event.linkTo( event.getValue('action') );
	</cfscript>
	
	<cfoutput>
	
	<br/>
	
    <div class="standardForm">
    
		<div id="tabs">	
			<ul>
		        <li><a href="##tabs-1">Role</a></li>
		        <li><a href="##tabs-2">Permissions</a></li>
		        <li><a href="##tabs-3">Preferences</a></li>
		    </ul>
		
	        <form action="#action#" method="post">
	        
				<div id="tabs-1">
			
				<fieldset>
			        <legend>Role</legend>
	    				
					<input type="hidden" id="Idrole" name="Idrole" value="#role.getIdrole()#" />
								
		            <label for="Name">Name</label>
					<input type="text" id="Name" name="Name" value="#role.getName()#" />
					<cfif structKeyExists( validator, 'Name' ) >
					<span class="formError">#validator['Name'][1]#</span>
					</cfif>
								
		            <label for="Description">Description</label>
					<cfif structKeyExists( validator, 'Description' ) >
					<span class="formError">#validator['Description'][1]#</span>
					</cfif>
					<textarea id="Description" name="Description" rows="10" cols="80" style="width: 80%" class="textareasimple">#role.getDescription()#</textarea>
				
				</fieldset>
				
				</div>
				
				<div id="tabs-2">
				
					<fieldset>
			        	<legend>Permissions</legend>
					
						<cfloop condition="#permissionList.hasNext()#">
						<cfset next = permissionList.next() />
		                <label for="#next.getId()#"><input name="permission" <cfif listFindNoCase( permissions, next.getIdPermission(), "," )>checked="checked"</cfif> id="#next.getId()#" value="#next.getIdpermission()#" type="checkbox" />#next.getName()#</label>
						</cfloop>
								
					</fieldset>
					
				</div>
				
				<div id="tabs-3">
				
					<fieldset>
			        	<legend>Preferences</legend>
					
						<cfloop condition="#preferenceList.hasNext()#">
						<cfset next = preferenceList.next() />
		                <label for="#next.getId()#"><input name="preference" <cfif listFindNoCase( preferences, next.getIdPreference(), "," )>checked="checked"</cfif> id="#next.getId()#" value="#next.getIdPreference()#" type="checkbox" />#next.getName()#</label>
						</cfloop>
					
					</fieldset>
				
				</div>
				
	            <br />
				
	            <div>
	                <input type="submit" value="Submit" class="formButton" />
	            </div>
				
				<br />
			
        	</form>
		
		</div>
		
		<br />
		
    </div>
		
    </cfoutput>